package com.lyk.coursearrange.controller;

import com.lyk.coursearrange.common.core.base.result.R;
import com.lyk.coursearrange.common.log.annotation.Log;
import com.lyk.coursearrange.common.log.enums.OperationType;
import com.lyk.coursearrange.entity.OperLog;
import com.lyk.coursearrange.entity.dto.OperLogDto;
import com.lyk.coursearrange.service.IOperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/operlog")
public class OperLogController
{
    @Autowired
    private IOperLogService operLogService;

    @PostMapping("/list")
    public R list(@RequestBody Map<String,String> param)
    {
        //创建list集合，存储OperLog实例对象
        List<OperLogDto> list = operLogService.selectOperLogList(param);
        return R.ok()
                .data("items",list)
                .data("total",list.size())
                .message("获取操作日志列表成功");
    }

    //@InnerAuth
    @PostMapping
    public R add(@RequestBody OperLog operLog)
    {
        //调用operLogService的insertOperlog方法存入操作日志表
        operLogService.insertOperlog(operLog);
        return R.ok().message("新增日志操作成功");
    }
}
